"""
	练习
"""
import 函数式编程应用.list_helper as so


class Enemy:
	def __init__(self, name, atk, blood, defense):
		self.name = name
		self.atk = atk
		self.blood = blood
		self.defense = defense

	def __str__(self):
		return f"{self.name}, {self.atk}, {self.blood}, {self.defense}"


enemy_list = [
	Enemy('灭霸', 20, 100, 10),
	Enemy('张三', 30, 100, 13),
	Enemy('李四', 40, 100, 12),
	Enemy('赵敏', 50, 100, 11),
	Enemy('成昆', 1, 10, 8)
]


print('查找姓名是灭霸的敌人')
for item in so.ListHelper.find_all(enemy_list, lambda sp: sp.name == "灭霸"):
	print(item)

print("查找攻击力大于10的敌人")
for item in so.ListHelper.find_all(enemy_list, lambda sp: sp.atk > 10):
	print(item)

print("查找活的敌人数量")
for item in so.ListHelper.find_all(enemy_list, lambda sp: sp.blood > 0):
	print(item)

print("判断敌人列表是否攻击力小于5或者防御力小于10的敌人")
for item in so.ListHelper.find_all(enemy_list, lambda sp: sp.atk < 5 or sp.defense < 10):
	print(item)
